$(function(){
	var $num = 24;
	$.ajax({
		type:"get",
		url:"js/list.json",
		async:false,
		success:function(msg){
			var $page = Math.ceil(msg.length/$num)
			for(var i = 0;i<$page;i++){
	 			$(".list_fybtn").append('<li>' + (i+1) + '</li>')
	 		};
	 		for (var i = 0; i <$num; i++) {
                if (msg[i]) {
                    $(".list_fyul").append('<li><dl><dt><img src='+msg[i].url+'></dt><dd><span>'+msg[i].name+'</span><br /><b>'+msg[i].text+'</b><br /><strong>'+msg[i].price+'</strong><br /><a href="#" style="background:#83c44e">'+msg[i].position+'</a></dd></dl></li>')
                }
            }
	 		$(".list_fyul>li").click(function(){
	 			location.href = 'detail.html';
	 		})
			$('.list_fybtn>li').click(function(){
				$(window).scrollTop(0);
				$(".list_fyul").empty();
				var $index = $(this).index();
				for (var i = 0 + ($num * $index); i < $num * (1 + $index); i++) {
                    $(".list_fyul").append('<li><dl><dt><img src='+msg[i].url+'></dt><dd><span>'+msg[i].name+'</span><br /><b>'+msg[i].text+'</b><br /><strong>'+msg[i].price+'</strong><br /><a href="#" style="background:#83c44e">'+msg[i].position+'</a></dd></dl></li>') 
                    }
			})
		}
	});
	
})
